package com;

import java.sql.Connection;
import java.sql.Statement;

public class JDBC_01_Batch_Statement {

	public static void main(String[] args) {
		Connection connection = null;
		Statement statement = null;
		try {
			connection = DBUtil.getConnection();
			long startTime = System.currentTimeMillis();
			statement = connection.createStatement();
			for (int i = 0; i < 100; i++) {
				statement.addBatch("insert into test (name,age) values ('张三_" + i + "',18)");

			}
			statement.executeBatch();
			long endTime = System.currentTimeMillis();
			System.out.println("执行成功 : " + (endTime - startTime));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				DBUtil.close(statement);
				DBUtil.close(connection);
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
	}

}
